home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland Pascal with Objects 7.0 / WDOCDEMO.ZIP / CBOXTEST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-27  |  3.6 KB  |  126 lines

  1. {************************************************}
  2. {                                                }
  3. {   ObjectWindows Demo                           }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. program CBoxTest;
  9.  
  10. uses WinTypes, WinProcs, OWindows, ODialogs;
  11.         
  12. const
  13.   id_LB1 = 101;
  14.   id_CB1 = 102;
  15.   id_CB2 = 103;
  16.   id_CB3 = 104;
  17.   id_BN1 = 105;
  18.   id_BN2 = 106;
  19.   id_ST1 = 107;
  20.   id_ST2 = 108;
  21.   id_ST3 = 109;
  22.   id_ST4 = 110;
  23.  
  24. type
  25.   TestApplication = object(TApplication)
  26.     procedure InitMainWindow; virtual;
  27.   end;
  28.  
  29.   PTestWindow = ^TestWindow;
  30.   TestWindow = object(TWindow)
  31.     LB1: PListBox;
  32.     CB1, CB2, CB3: PComboBox;
  33.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  34.     procedure SetupWindow; virtual;
  35.     procedure IDBN1(var Msg: TMessage); virtual id_First + id_BN1;
  36.     procedure IDBN2(var Msg: TMessage); virtual id_First + id_BN2;
  37.   end;
  38.  
  39. {--------------------------------------------------}
  40. { TestWindow's method implementations:             }
  41. {--------------------------------------------------} 
  42.  
  43. constructor TestWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  44. var
  45.   ABtn : PButton;
  46.   AStat : PStatic;
  47. begin
  48.   inherited Init(AParent, ATitle);
  49.   LB1 := New(PListBox, Init(@Self, id_LB1, 20, 30, 150, 100));
  50.   CB1 := New(PComboBox, Init(@Self, id_CB1, 190, 30, 150, 100, cbs_Simple, 0));
  51.   CB1^.Attr.Style := CB1^.Attr.Style and not ws_VScroll;
  52.   CB2 := New(PComboBox, Init(@Self, id_CB2, 20, 160, 150, 100, cbs_DropDown, 0));
  53.   CB3 := New(PComboBox, Init(@Self, id_CB3, 190, 160, 150, 100, cbs_DropDownList, 0));
  54.   ABtn := New(PButton, Init(@Self, id_BN1, 'Show', 190, 270, 65, 20, False));
  55.   ABtn := New(PButton, Init(@Self, id_BN2, 'Hide', 275, 270, 65, 20, False));
  56.   AStat := New(PStatic, Init(@Self, id_ST1, 'List Box', 20, 8, 150, 20, 0));
  57.   AStat := New(PStatic, Init(@Self, id_ST2, 'Simple Combo', 190, 8, 150, 20, 0));
  58.   AStat := New(PStatic, Init(@Self, id_ST3, 'Drop Down Combo', 20, 138, 150, 20, 0));
  59.   AStat := New(PStatic, Init(@Self, id_ST4, 'Drop Down List Combo', 190, 138, 150, 20, 0));
  60. end;
  61.  
  62. procedure TestWindow.SetupWindow;
  63. begin
  64.   inherited SetupWindow;
  65.   LB1^.AddString('a');
  66.   LB1^.AddString('b');
  67.   LB1^.AddString('c');
  68.   LB1^.AddString('d');
  69.   LB1^.AddString('e');
  70.   LB1^.AddString('f');
  71.   
  72.   CB1^.AddString('a');
  73.   CB1^.AddString('b');
  74.   CB1^.AddString('c');
  75.   CB1^.AddString('d');
  76.   CB1^.AddString('e');
  77.   CB1^.AddString('f');
  78.  
  79.   CB2^.AddString('a');
  80.   CB2^.AddString('b');
  81.   CB2^.AddString('c');
  82.   CB2^.AddString('d');
  83.   CB2^.AddString('e');
  84.   CB2^.AddString('f');
  85.  
  86.   CB3^.AddString('a');
  87.   CB3^.AddString('b');
  88.   CB3^.AddString('c');
  89.   CB3^.AddString('d');
  90.   CB3^.AddString('e');
  91.   CB3^.AddString('f');
  92. end;
  93.  
  94. procedure TestWindow.IDBN1(var Msg: TMessage);
  95. begin
  96.   { Respond to the 'Show' button being pressed. }
  97.   CB3^.ShowList;
  98. end;
  99.  
  100. procedure TestWindow.IDBN2(var Msg: TMessage);
  101. begin
  102.   { Respond to the 'Hide' button being pressed. }
  103.   CB3^.HideList;
  104. end;
  105.  
  106. {--------------------------------------------------}
  107. { TestApplication's method implementations:        }
  108. {--------------------------------------------------} 
  109.  
  110. procedure TestApplication.InitMainWindow;
  111. begin
  112.   MainWindow := New(PTestWindow, Init(nil, 'Combo Box Tester'));
  113. end;
  114.  
  115. {--------------------------------------------------}
  116. { Main program:                                    }
  117. {--------------------------------------------------} 
  118.  
  119. var
  120.   TestApp : TestApplication;
  121. begin
  122.   TestApp.Init('CBoxTest');
  123.   TestApp.Run;
  124.   TestApp.Done;
  125. end.
  126.